package com.portal.innovation.sysController;


import com.portal.innovation.common.R;
import com.portal.innovation.pojo.PhotoWall;
import com.portal.innovation.service.PhotoWallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * 文件上传控制器
 */
@RestController
@RequestMapping("/photo")
public class PhotoWallController {

    @Autowired
    private PhotoWallService photoWallService;

    @PostMapping("listAll")
    public R save() {
        List<PhotoWall> data = photoWallService.list();
        return R.ok().put("data", data);
    }

    @PostMapping("save")
    public R save(@RequestBody PhotoWall photoWall) {
        photoWallService.save(photoWall);
        return R.ok();
    }

    @DeleteMapping("delete")
    public R save(@RequestBody Integer[] ids) {
        photoWallService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

    @PostMapping("update")
    public R update(@RequestBody PhotoWall photoWall) {
        photoWallService.updateById(photoWall);
        return R.ok();
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {
        PhotoWall photoWall = photoWallService.getById(id);
        return R.ok().put("photoWall", photoWall);
    }

}
